/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('ailab-vision-public', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model CalibRequest {
  sceneId?: string(name='sceneId'),
  floorId?: string(name='floorId'),
  cameraId?: string(name='cameraId'),
  featureMatch?: {
    img0?: string(name='img0'),
    img1?: string(name='img1'),
    matchNum?: long(name='match_num'),
    img0Kpts?: [[ float ]    ](name='img0_kpts'),
    img1Kpts?: [[ float ]    ](name='img1_kpts'),
  }(name='featureMatch'),
  cameraType?: string(name='cameraType'),
  zoomLevel?: string(name='zoomLevel'),
  kptsNum?: string(name='kptsNum'),
  reprojectThresh?: string(name='reprojectThresh'),
}

model CalibResponseBody = {
  success?: long(name='success'),
  errmsg?: string(name='errmsg'),
  results?: {
    hCam2map?: [[ float ]    ](name='H_cam2map'),
    t?: [ float ](name='t'),
    q?: [ float ](name='Q'),
    camInmap?: [ float ](name='cam_inmap'),
  }(name='results'),
}

model CalibResponse = {
  headers: map[string]string(name='headers'),
  body: CalibResponseBody(name='body'),
}

async function calib(request: CalibRequest): CalibResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return calibWithOptions(request, headers, runtime);
}

async function calibWithOptions(request: CalibRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CalibResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.sceneId)) {
    body.sceneId = request.sceneId;
  }
  if (!Util.isUnset(request.floorId)) {
    body.floorId = request.floorId;
  }
  if (!Util.isUnset(request.cameraId)) {
    body.cameraId = request.cameraId;
  }
  if (!Util.isUnset(request.featureMatch)) {
    body.featureMatch = request.featureMatch;
  }
  if (!Util.isUnset(request.cameraType)) {
    body.cameraType = request.cameraType;
  }
  if (!Util.isUnset(request.zoomLevel)) {
    body.zoomLevel = request.zoomLevel;
  }
  if (!Util.isUnset(request.kptsNum)) {
    body.kptsNum = request.kptsNum;
  }
  if (!Util.isUnset(request.reprojectThresh)) {
    body.reprojectThresh = request.reprojectThresh;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  return doROARequest('Calib', '2021-07-09', 'HTTPS', 'POST', 'AK', `/api/predict/calib`, 'json', req, runtime);
}

model ReidBodyRequest {
  pictureUrl?: [ string ](name='pictureUrl', description='pictureUrl list'),
}

model ReidBodyResponseBody = {
  success?: long(name='success'),
  errmsg?: string(name='errmsg'),
  vector?: [[ float ]  ](name='vector'),
  valid?: [ long ](name='valid'),
}

model ReidBodyResponse = {
  headers: map[string]string(name='headers'),
  body: ReidBodyResponseBody(name='body'),
}

async function reidBody(request: ReidBodyRequest): ReidBodyResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return reidBodyWithOptions(request, headers, runtime);
}

async function reidBodyWithOptions(request: ReidBodyRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ReidBodyResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.pictureUrl)) {
    body.pictureUrl = request.pictureUrl;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  return doROARequest('ReidBody', '2021-07-09', 'HTTPS', 'POST', 'AK', `/api/predict/reid_pub`, 'json', req, runtime);
}

model AttrBodyRequest {
  pictureUrl?: [ string ](name='pictureUrl', description='pic list'),
}

model AttrBodyResponseBody = {
  success?: long(name='success'),
  errmsg?: string(name='errmsg'),
  attributes?: [ 
    {
      gender?: string(name='gender'),
      genderScore?: float(name='genderScore'),
      age?: string(name='age'),
      ageScore?: float(name='ageScore'),
      direction?: string(name='direction'),
      directionScore?: float(name='directionScore'),
      quality?: float(name='quality'),
    }
  ](name='attributes'),
  valid?: [ long ](name='valid'),
}

model AttrBodyResponse = {
  headers: map[string]string(name='headers'),
  body: AttrBodyResponseBody(name='body'),
}

async function attrBody(request: AttrBodyRequest): AttrBodyResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return attrBodyWithOptions(request, headers, runtime);
}

async function attrBodyWithOptions(request: AttrBodyRequest, headers: map[string]string, runtime: Util.RuntimeOptions): AttrBodyResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.pictureUrl)) {
    body.pictureUrl = request.pictureUrl;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  return doROARequest('AttrBody', '2021-07-09', 'HTTPS', 'POST', 'AK', `/api/attr_body`, 'json', req, runtime);
}

model ReidFaceRequest {
  pictureUrl?: [ string ](name='pictureUrl', description='pic list'),
}

model ReidFaceResponseBody = {
  success?: long(name='success'),
  errmsg?: string(name='errmsg'),
  vector?: [[ float ]  ](name='vector'),
  valid?: [ long ](name='valid'),
}

model ReidFaceResponse = {
  headers: map[string]string(name='headers'),
  body: ReidFaceResponseBody(name='body'),
}

async function reidFace(request: ReidFaceRequest): ReidFaceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return reidFaceWithOptions(request, headers, runtime);
}

async function reidFaceWithOptions(request: ReidFaceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ReidFaceResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.pictureUrl)) {
    body.pictureUrl = request.pictureUrl;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  return doROARequest('ReidFace', '2021-07-09', 'HTTPS', 'POST', 'AK', `/api/reid_face`, 'json', req, runtime);
}

model AttrFaceRequest {
  pictureUrl?: [ string ](name='pictureUrl', description='["xxx1.jpg", "xxx2.jpg"]'),
}

model AttrFaceResponseBody = {
  success?: long(name='success'),
  errmsg?: string(name='errmsg'),
  attributes?: [ 
    {
      age?: float(name='age'),
      ageScore?: float(name='ageScore'),
      gender?: string(name='gender'),
      genderScore?: float(name='genderScore'),
      mask?: string(name='mask'),
      angle?: [ float ](name='angle'),
      score?: float(name='score'),
    }
  ](name='attributes'),
  valid?: [ long ](name='valid'),
}

model AttrFaceResponse = {
  headers: map[string]string(name='headers'),
  body: AttrFaceResponseBody(name='body'),
}

async function attrFace(request: AttrFaceRequest): AttrFaceResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return attrFaceWithOptions(request, headers, runtime);
}

async function attrFaceWithOptions(request: AttrFaceRequest, headers: map[string]string, runtime: Util.RuntimeOptions): AttrFaceResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.pictureUrl)) {
    body.pictureUrl = request.pictureUrl;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  return doROARequest('AttrFace', '2021-07-09', 'HTTPS', 'POST', 'AK', `/api/attr_face`, 'json', req, runtime);
}

model MatchRequest {
  pictureUrl?: string(name='pictureUrl'),
  sceneId?: string(name='sceneId'),
  floorId?: string(name='floorId'),
  cameraId?: string(name='cameraId'),
  cameraCoord?: [ float ](name='cameraCoord'),
}

model MatchResponseBody = {
  success?: long(name='success'),
  errmsg?: string(name='errmsg'),
  results?: string(name='results'),
}

model MatchResponse = {
  headers: map[string]string(name='headers'),
  body: MatchResponseBody(name='body'),
}

async function match(request: MatchRequest): MatchResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return matchWithOptions(request, headers, runtime);
}

async function matchWithOptions(request: MatchRequest, headers: map[string]string, runtime: Util.RuntimeOptions): MatchResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.pictureUrl)) {
    body.pictureUrl = request.pictureUrl;
  }
  if (!Util.isUnset(request.sceneId)) {
    body.sceneId = request.sceneId;
  }
  if (!Util.isUnset(request.floorId)) {
    body.floorId = request.floorId;
  }
  if (!Util.isUnset(request.cameraId)) {
    body.cameraId = request.cameraId;
  }
  if (!Util.isUnset(request.cameraCoord)) {
    body.cameraCoord = request.cameraCoord;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  return doROARequest('Match', '2021-07-09', 'HTTPS', 'POST', 'AK', `/api/predict/match`, 'json', req, runtime);
}

